﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BbsbWsGui
{
    public static class Helper
    {
        public static IEnumerable<T> GetUniquePropertyList<S, T>(this IEnumerable<S> list, Func<S, T> func)
        {
            List<T> newList = new List<T>();
            foreach (var item in list)
            {
                T subItem = func.Invoke(item);
                if (!newList.Contains(subItem))
                {
                    newList.Add(subItem);
                }
            }

            return newList;
        }

        public static string Join<T, S>(this IEnumerable<T> list, string seperator, Func<T, S> func)
        {
            List<S> bob = new List<S>();
            foreach (var item in list)
            {
                bob.Add(func.Invoke(item));
            }

            string bob2 = string.Join(seperator, bob);

            return bob2;
        }
    }
}
